from flask_restful import fields  # type: ignore
from fields.character_fields_def import base_character_fields
from libs.helper import TimestampField
from fields.timbre_fields_def import base_timbre_fields
from fields.emoji_pack_fields_def import base_emoji_pack_fields
rob_account_extra_info_fields = {
    "id": fields.String,
    "user_name": fields.String,
    "robot_name": fields.String,
    "phone": fields.String,
    "postal_code": fields.Integer,
    "district": fields.String,
    "extra_info":  fields.Raw,
    "last_ip": fields.String,
    "last_login_at": TimestampField,
    "tenant_id": fields.String(attribute="robot.tenant_id"),
    "h_version": fields.String(attribute="robot.h_version"),
    "f_version": fields.String(attribute="robot.f_version"),
    "activated_at": TimestampField(attribute="robot.activated_at"),
    "agent_type": fields.String(attribute="robot.agent_type"),
    "fun_domain_id": fields.String(attribute="robot.fun_domain_id"),
    "cur_emoji_pack_id": fields.String(attribute="robot.cur_emoji_pack_id"),
    "cur_timbre_id": fields.String(attribute="robot.cur_timbre_id"),
    "cur_charater_id": fields.String(attribute="robot.cur_charater_id"),
    "extra_timbres": fields.Raw(attribute="robot.extra_timbres"),
    "extra_funcs": fields.Raw(attribute="robot.extra_funcs"),
    "extra_emoji_packs": fields.Raw(attribute="robot.extra_emoji_packs"),
    "bluetooth_id":fields.String(attribute="robot.bluetooth"),
    "created_at": TimestampField(attribute="robot.created_at"),
    "created_by": fields.String(attribute="robot.created_by"),
    "updated_at": TimestampField(attribute="robot.updated_at"),
    "updated_by": fields.String(attribute="robot.updated_by"),
}
rob_account_extra_plus_info_fields = {
    "id": fields.String,
    "user_name": fields.String,
    "robot_name": fields.String,
    "phone": fields.String,
    "postal_code": fields.Integer,
    "district": fields.String,
    "extra_info":  fields.Raw,
    "last_ip": fields.String,
    "last_login_at": TimestampField,
    "tenant_id": fields.String(attribute="robot.tenant_id"),
    "h_version": fields.String(attribute="robot.h_version"),
    "f_version": fields.String(attribute="robot.f_version"),
    "activated_at": TimestampField(attribute="robot.activated_at"),
    "agent_type": fields.String(attribute="robot.agent_type"),
    "fun_domain_id": fields.String(attribute="robot.fun_domain_id"),
    "cur_emoji_pack_id": fields.String(attribute="robot.cur_emoji_pack_id"),
    "cur_timbre_id": fields.String(attribute="robot.cur_timbre_id"),
    "cur_charater_id": fields.String(attribute="robot.cur_charater_id"),
    "extra_timbres": fields.Raw(attribute="robot.extra_timbres"),
    "extra_funcs": fields.Raw(attribute="robot.extra_funcs"),
    "extra_emoji_packs": fields.Raw(attribute="robot.extra_emoji_packs"),
    "bluetooth_id":fields.String(attribute="robot.bluetooth"),
    "created_at": TimestampField(attribute="robot.created_at"),
    "created_by": fields.String(attribute="robot.created_by"),
    "updated_at": TimestampField(attribute="robot.updated_at"),
    "updated_by": fields.String(attribute="robot.updated_by"),
    "current_character":fields.Nested(base_character_fields),
    "current_timbre":fields.Nested(base_timbre_fields),
    "current_emoji_pack":fields.Nested(base_emoji_pack_fields),
}
base_rob_extra_info_fields = {
    "id": fields.String,
    "user_name": fields.String,
    "robot_name": fields.String,
    "phone": fields.String,
    "postal_code": fields.Integer,
    "district": fields.String,
    "extra_info":  fields.Raw,
    "last_ip": fields.String,
    "last_login_at": TimestampField,
}
character_name_fields={
    "id":fields.String,
    "name":fields.String,
}
robot_fields = {
    "id": fields.String(),
    "tenant_id": fields.String(),
    "bluetooth_id":fields.String(),
    "hardware_version": fields.String(attribute="h_version"),
    "fireware_version": fields.String(attribute="f_version"),
    "activated_at": TimestampField(),
    "agent_type": fields.String(),
    "fun_domain_id": fields.String(),
    "cur_emoji_pack_id": fields.String(),
    "cur_timbre_id": fields.String(),
    "cur_charater_id": fields.String(),
    "extra_timbres": fields.Raw(),
    "extra_funcs": fields.Raw(),
    "extra_emoji_packs": fields.Raw(),
    "created_at": TimestampField(),
    "created_by": fields.String(),
    "updated_at": TimestampField(),
    "updated_by": fields.String(),
    "characters": fields.List(fields.Nested(character_name_fields))
}

robot_list_fields = {
    "total":fields.Integer(),
    "has_more":fields.Boolean(),
    "data":fields.List(fields.Nested(robot_fields))
}

robot_import_fields={
    "data":fields.List(fields.Nested(robot_fields)),
    "messages":fields.List(fields.String),
    "len":fields.Integer
}